package com.simon.train.business.controller.admin;


import com.simon.train.business.dto.ConfirmOrderQueryDto;
import com.simon.train.business.dto.ConfirmOrderSaveDto;
import com.simon.train.business.service.ConfirmOrderService;
import com.simon.train.business.vo.ConfirmOrderQueryVO;
import com.simon.train.common.Result.Result;
import com.simon.train.common.vo.PageVO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/confirmOrder")
public class ConfirmOrderAdminController {

    @Resource
    private ConfirmOrderService confirmOrderService;

    @PostMapping("/save")
    public Result<Object> SaveConfirmOrder(@Valid @RequestBody ConfirmOrderSaveDto confirmOrderSaveDto){
        confirmOrderService.SaveConfirmOrder(confirmOrderSaveDto);
        return new Result<>();
    }

    @GetMapping("/queryList")
    public Result<PageVO<ConfirmOrderQueryVO>> ConfirmOrderQueryList(@Valid ConfirmOrderQueryDto confirmOrderQueryDto){
         /**
         * businessId通过线程变量获取 从而不需要由前端传入 保证了效率和安全性
         */
        PageVO<ConfirmOrderQueryVO> lists = confirmOrderService.QueryConfirmOrderList(confirmOrderQueryDto);
        return new Result<>(lists);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Object> DeleteConfirmOrder(@PathVariable("id") Long id){
        confirmOrderService.deleteConfirmOrder(id);
        return new Result<>();
    }

}
